package com.xcx.common.dto.base;

import com.xcx.common.enums.RespCodeEnum;
import com.xcx.common.utils.RandomUtil;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
public class BaseResp extends BaseDto {
    private static final long serialVersionUID = 32039449334431L;
    /**
     * 请求号
     */
    private String reqNo;
    /**
     * 响应号
     */
    private String respNo;
    /**
     * 响应码
     */
    private String respCode;
    /**
     * 响应描述
     */
    private String respDesc;

    public boolean isSuccess() {
        return RespCodeEnum.SUCCESS.getCode().equalsIgnoreCase(this.respCode);
    }

    public void buildDefaultSuccessResp() {
        respCode = RespCodeEnum.SUCCESS.getCode();
        respDesc = RespCodeEnum.SUCCESS.getMessage();
    }

    public void buildDefaultSuccessResp(BaseReq baseReq) {
        respCode = RespCodeEnum.SUCCESS.getCode();
        respDesc = RespCodeEnum.SUCCESS.getMessage();
        reqNo = baseReq.getReqNo();
        respNo = RandomUtil.getRandomNum(5);
    }
}
